winsafe\mf\com_interfaces/
imfasyncresult.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use std::mem::ManuallyDrop;
4
5use crate::co;
6use crate::decl::*;
7use crate::mf::vts::*;
8use crate::ole::privs::*;
9use crate::prelude::*;
10
11com_interface! { IMFAsyncResult: "ac6b7889-0740-4d51-8619-905994a55cc6";
12	/// [`IMFAsyncResult`](https://learn.microsoft.com/en-us/windows/win32/api/mfobjects/nn-mfobjects-imfasyncresult)
13	/// COM interface.
14	///
15	/// Automatically calls
16	/// [`Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
17	/// when the object goes out of scope.
18}
19
20impl mf_IMFAsyncResult for IMFAsyncResult {}
21
22/// This trait is enabled with the `mf` feature, and provides methods for
23/// [`IMFAsyncResult`](crate::IMFAsyncResult).
24///
25/// Prefer importing this trait through the prelude:
26///
27/// ```no_run
28/// use winsafe::prelude::*;
29/// ```
30pub trait mf_IMFAsyncResult: ole_IUnknown {
31	/// [`IMFAsyncResult::GetObject`](https://learn.microsoft.com/en-us/windows/win32/api/mfobjects/nf-mfobjects-imfasyncresult-getobject)
32	/// method.
33	#[must_use]
34	fn GetObject<T>(&self) -> HrResult<T>
35	where
36		T: ole_IUnknown,
37	{
38		let mut queried = unsafe { T::null() };
39		ok_to_hrresult(unsafe {
40			(vt::<IMFAsyncResultVT>(self).GetObject)(self.ptr(), queried.as_mut())
41		})
42		.map(|_| queried)
43	}
44
45	/// [`IMFAsyncResult::GetState`](https://learn.microsoft.com/en-us/windows/win32/api/mfobjects/nf-mfobjects-imfasyncresult-getstate)
46	/// method.
47	#[must_use]
48	fn GetState<T>(&self) -> HrResult<T>
49	where
50		T: ole_IUnknown,
51	{
52		let mut queried = unsafe { T::null() };
53		ok_to_hrresult(unsafe {
54			(vt::<IMFAsyncResultVT>(self).GetState)(self.ptr(), queried.as_mut())
55		})
56		.map(|_| queried)
57	}
58
59	/// [`IMFAsyncResult::GetStateNoAddRef`](https://learn.microsoft.com/en-us/windows/win32/api/mfobjects/nf-mfobjects-imfasyncresult-getstatenoaddref)
60	/// method.
61	#[must_use]
62	fn GetStateNoAddRef<T>(&self) -> Option<ManuallyDrop<T>>
63	where
64		T: ole_IUnknown,
65	{
66		let ptr = unsafe { (vt::<IMFAsyncResultVT>(self).GetStateNoAddRef)(self.ptr()) };
67		if ptr.is_null() { None } else { Some(ManuallyDrop::new(unsafe { T::from_ptr(ptr) })) }
68	}
69
70	/// [`IMFAsyncResult::GetStatus`](https://learn.microsoft.com/en-us/windows/win32/api/mfobjects/nf-mfobjects-imfasyncresult-getstatus)
71	/// method.
72	#[must_use]
73	fn GetStatus(&self) -> co::HRESULT {
74		unsafe { co::HRESULT::from_raw((vt::<IMFAsyncResultVT>(self).GetStatus)(self.ptr())) }
75	}
76
77	/// [`IMFAsyncResult::SetStatus`](https://learn.microsoft.com/en-us/windows/win32/api/mfobjects/nf-mfobjects-imfasyncresult-setstatus)
78	/// method.
79	fn SetStatus(&self, status: co::HRESULT) -> HrResult<()> {
80		ok_to_hrresult(unsafe {
81			(vt::<IMFAsyncResultVT>(self).SetStatus)(self.ptr(), status.raw())
82		})
83	}
84}